package ClassExercise;

import java.util.Scanner;

public class Exercise2 {
    //根据输入的身份证号码实现输出日的出生日期
    public static void main(String[] args) {
        Scanner sr = new Scanner(System.in);
        final int INITIALNUMBER=3;
        int count=0;
        String sfz;
        for(;;){
            if (count==0){
                System.out.print("您有"+(INITIALNUMBER-count)+"次机会进行输入,请输入:");
            }else{
                System.out.print("您还有"+(INITIALNUMBER-count)+"次机会进行输入,请输入:");
            }
            sfz = sr.next();
            if(sfz.length()==18){
                String str = sfz.substring(6,14);
                System.out.println("恭喜您输入正确!!");
                System.out.print("您的出生日期为:");
                System.out.println(Integer.parseInt(str));
                break;
            }else{
                count++;
                if(count==3){
                    System.out.println("很可惜，您已经没有机会进行输入了！！");
                    break;
                }
                continue;
            }
        }
    }
}
